package extrace.loader;

import android.app.Activity;
import android.app.ProgressDialog;
import android.util.Log;
import android.widget.Toast;

import com.google.gson.reflect.TypeToken;

import extrace.misc.model.ExpressSheet;
import extrace.misc.model.Rp;
import extrace.misc.model.TransPackage;
import extrace.net.HttpAsyncTask;
import extrace.net.HttpResponseParam.RETURN_STATUS;
import extrace.net.IDataAdapter;
import extrace.net.JsonUtils;
import extrace.ui.main.ExTraceApplication;

public class SDPackageLoader extends HttpAsyncTask {


	String url;
	int uid;
	private Activity context;

	public SDPackageLoader( Activity context) {
		super(context);
		this.context = context;

		uid=((ExTraceApplication)context.getApplication()).getLoginUser().getUID();
		url = ((ExTraceApplication)context.getApplication()).getDomainServiceUrl();
	}

	@Override
	public void onDataReceive(String class_name, String json_data) {



	}

	@Override
	public void onDataReceive(String json_data) {
		Rp r= JsonUtils.fromJson(json_data,new TypeToken<Rp<Object>>(){});
		Log.i("TAG", "onDataReceive: "+r.getMsg());
		Toast.makeText(context, r.getMsg(), Toast.LENGTH_SHORT).show();

	}

	@Override
	public void onStatusNotify(RETURN_STATUS status, String str_response) {
		// TODO Auto-generated method stub
		
	}

	public void Dispatch(String pkg)
	{
		url += "dispatchedPackage/pkg/"+pkg +"/uid/"+ uid + "?_type=json";
		try {
			execute(url, "GET");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void Split(String pkg)
	{
		url += "splitedPackage/pkg/"+ pkg +"/uid/"+uid+ "?_type=json";
		try {
			execute(url, "GET");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
